#!/bin/sh

PREREQ=""
DESCRIPTION="Adding Student user..."

. /scripts/casper-functions

prereqs()
{
       echo "$PREREQ"
}

case $1 in
# get pre-requisites
prereqs)
       prereqs
       exit 0
       ;;
esac

log_begin_msg "$DESCRIPTION"

# U6aMy0wojraho is just a blank password
# DIGEKS TF 15.10.2008: Cannot use blank password!!
# Created password with 'openssl passwd -crypt' and typed in password
chroot /root debconf-communicate -fnoninteractive casper > /dev/null <<EOF
set passwd/root-password-crypted 6iE5HxDU15BYw
set passwd/user-password-crypted 6iE5HxDU15BYw
set passwd/user-fullname $USERFULLNAME
set passwd/username $USERNAME
set passwd/user-uid 1007
EOF

chroot /root /usr/lib/user-setup/user-setup-apply > /dev/null


# DIGEKS 15.10.2008: Removed "NOPASSWD:" from all options, since 
# we WANT the user of the system to specify password to use sudo command
if [ -f /root/etc/sudoers ]; then
    if [ "${BUILD_SYSTEM}" = "Ubuntu" ]; then
	if grep -q '^%admin' /root/etc/sudoers; then
	    sed -i -e '/^%admin/s/(ALL) ALL$/(ALL)  ALL/' /root/etc/sudoers
	else
	    echo '%admin  ALL=(ALL)  ALL' >> /root/etc/sudoers
	fi
    elif [ "${BUILD_SYSTEM}" = "Debian" ]; then
		echo "${USERNAME}  ALL=(ALL)  ALL" >> /root/etc/sudoers
    fi
fi

# XXX - awful hack to stop xscreensaver locking the screen (#7150)
echo 'RUNNING_UNDER_GDM="yes"' >> /root/etc/environment


# DIGEKS: Do not want anything extra in Desktop-directory
#for file in /usr/share/applications/ubiquity-gtkui.desktop /usr/share/applications/kde/ubiquity-kdeui.desktop; do
#    if [ -f "/root/$file" ]; then
#        chroot /root install -d -o $USERNAME -g $USERNAME /home/$USERNAME/Desktop
#        chroot /root install -D -o $USERNAME -g $USERNAME $file /home/$USERNAME/Desktop/$(basename "$file")
#        break
#    fi
#done

# DIGEKS: Do not want Examples directory
#if [ -L /root/home/$USERNAME/Examples ]; then
#    chroot /root install -o $USERNAME -g $USERNAME -d /home/$USERNAME/Desktop/
#    mv /root/home/$USERNAME/Examples /root/home/$USERNAME/Desktop/
#fi

# DIGEKS: Do not want the "About Kubuntu" icon to appear
#Kubuntu (KDE 3)
#if [ -f "/root/usr/bin/konqueror" ]; then
#    if [ -f "/root/usr/share/apps/khelpcenter/plugins/kubuntu/about-kubuntu.desktop.tobemoved" ]; then
#      chroot /root install -d -o $USERNAME -g $USERNAME /home/$USERNAME/Desktop
#      chroot /root install -D -o $USERNAME -g $USERNAME /usr/share/apps/khelpcenter/plugins/kubuntu/about-kubuntu.desktop.tobemoved /home/$USERNAME/Desktop/about-kubuntu.desktop
#    fi
#fi

# DIGEKS: Do not want the "About Kubuntu" icon to appear
#Kubuntu (KDE 4)
#if [ -f "/root/usr/lib/kde4/bin/plasma" ]; then
#    if [ -f "/root/usr/share/apps/khelpcenter/plugins/kubuntu/about-kubuntu.desktop.tobemoved" ]; then
#      chroot /root install -d -o $USERNAME -g $USERNAME /home/$USERNAME/Desktop
      #chroot /root ln -s /usr/share/doc/kde/HTML/en/kubuntu/about-kubuntu/index.html "/home/$USERNAME/Desktop/About Kubuntu"
#      chroot /root chown $USERNAME.$USERNAME "/home/$USERNAME/Desktop/About Kubuntu"
#    fi
#fi

log_end_msg
